
import {DIC }from '@/const/dic.js';
import {isvalidatemobile,validatenull,validateEmail} from '@/util/validate.js'
var validatePhone = (rule, value, callback) => {

    var  list=isvalidatemobile(value);
    if (!validatenull(value)) {
        if (list[0]) {
            callback(new Error(list[1]));
        } else {
            callback();
        }
    } else {
        callback(new Error(list[1]));
    }

}
var validateEmail1 =(rule,value,callback)=>{
    if(!validatenull(value)){
        if(!validateEmail(value)){
            callback(new Error("邮箱格式不正确"))
        }else {
            callback();
        }
    } else {
        callback(new Error('请输入邮箱'));
    }
}
var password="";
var validatePass =(rule,value,callback)=>{
    password=value;
    if(validatenull(value)){
        callback(new Error('请输入密码'));
    } else {
        callback();
    }
}
var validatePass1 =(rule,value,callback)=>{
    if (validatenull(value)) {
        callback(new Error('请再次输入密码'));
    } else if (value != password) {
        callback(new Error('两次输入密码不一致!'));
    } else {
        callback();
    }
}

export const usrUserOption = {
    border: true,
    index: true,
    indexLabel: '序号',
    selection: true,
    columnBtn:true,//是否可以控制表格内的列
    // refreshBtn:true,//是否显示刷新按钮
    addBtn:false,
    delBtn:false,
    editBtn:false,
    menuWidth:300,//操作栏宽度
    menuAlign:'center',
    formWidth: '100%',
    align:'center',
    dicData:DIC,
    stripe:true,
    expand:true,
    column: [
    {
                label: "编号",
                prop: "id",
                width: "150",
                fixed: true,
                hide:true,
                addDisplay:false,
                editDisplay:false,
                rules: [{
                    required: true,
                    message: "请输入编号",
                    trigger: "blur"
                }]
            },
        /**用户账号*/
        {
            label:"用户账号",
            prop:"userName",
            width:"150",
            fixed: true,
            rules: [{
                required: true,
                message: "请输入用户账号",
                trigger: "blur"
            }]
        },
        /**手机号*/
        {
            label:"手机号",
            prop:"mobile",
            width:"150",
            fixed: true,
            type:"phone",
            hide:true,
            expand:true,
            editDisplay:false,
            rules: [{
                required: true,
                validator: validatePhone,
                trigger: "blur"
            }]
        },
        /**性别*/
        {
            label: "性别",
            prop: "sex",
            type: "radio",
            fixed:true,
            dicData: DIC.SEX,
            valueDefault: 0,
            rules: [{
                required: true,
                message: "性别",
                trigger: "blur"
            }],
        },

        /**生日*/
        {
            label:"出生日期",
            prop:"birthday",
            width:"150",
            type: "date",
            fixed: true,
            format: 'yyyy-MM-dd',

            rules: [{
                required: true,
                message: "请选择出生日期",
                trigger: "blur"
            }]
        },
        /**密码*/
        {
            label:"密码",
            prop:"password",
            width:"150",
            type:"password",
            hide:true,
            expand:true,
            fixed: true,
            rules: [{
                required: true,
                validator: validatePass,
                trigger: "blur"
            }]
        },
        /**确认密码*/
        {
            label:"确认密码",
            width:"150",
            type:"password",
            prop:"password1",
            fixed: true,
            hide:true,
            editDisplay:false,
            viewDisplay:false,
            placeholder:"请再次输入密码",
            rules: [{
                required: true,
                validator: validatePass1,
                trigger: "blur"
            }]
        },
        /**地区*/

        {
            label:"地区",
            prop:"areaId",
            width:"150",
            fixed: true,
            hide:true,
            expand:true,
            // type: 'select',
            // cascader: ['city', 'area'],
            // cascaderFirst: true,
            // // dicUrl: `${baseUrl}/getProvince`,
            // dicData: 'province',
            rules: [{
                required: true,
                message: "请选择地区",
                trigger: "blur"
            }]
        },
        /**常住地址*/
        {
        label:"常住地址",
        prop:"address",
        width:"150",
        overHidden:true,

       fixed: true,
            rules: [{
                   required: true,
                   message: "请输入常住地址",
                   trigger: "blur"
               }]
        },

        /**QQ号*/
        {
            label:"QQ号",
            prop:"qq",
            width:"150",
            fixed: true,
            hide:true,
            expand:true,
            addDisplay:false,
            editDisplay:false,
            rules: [{
                required: true,
                message: "请输入QQ号",
                trigger: "blur"
            }]
        },
        /**微信号*/
        {
            label:"微信号",
            prop:"wechat",
            width:"150",
            fixed: true,
            hide:true,
            expand:true,
            addDisplay:false,
            editDisplay:false,
            rules: [{
                required: true,
                message: "请输入微信号",
                trigger: "blur"
            }]
        },

        /**邮箱*/
        {
        label:"邮箱",
        prop:"email",
        width:"150",
            // overHidden:true,
            hide:true,
            expand:true,
            addDisplay:false,
            editDisplay:false,
       fixed: true,
            rules: [{
                   required: true,
                validator: validateEmail1,
                   trigger: "blur"
               }]
        },

        /**可用余额*/
        {
            label:"可用余额",
            prop:"availableBalance",
            width:"150",
            fixed: true,
            addDisplay:false,
            editDisplay:false,
            hide:true,
            expand:true,
            rules: [{
                required: true,
                message: "可用余额",
                trigger: "blur"
            }]
        },
        /**冻结余额*/
        {
        label:"冻结余额",
        prop:"freezeBlance",
        width:"150",
       fixed: true,
            addDisplay:false,
            editDisplay:false,
            hide:true,
            expand:true,
            rules: [{
                   required: true,
                   message: "冻结余额",
                   trigger: "blur"
               }]
        },
        /**金币*/
        {
        label:"金币",
        prop:"gold",
        width:"150",
       fixed: true,
            addDisplay:false,
            editDisplay:false,
            hide:true,
            expand:true,
            rules: [{
                   required: true,
                   message: "金币",
                   trigger: "blur"
               }]
        },
        /**积分*/
        {
        label:"积分",
        prop:"integral",
        width:"150",
       fixed: true,
            addDisplay:false,
            editDisplay:false,
            hide:true,
            expand:true,
            rules: [{
                   required: true,
                   message: "积分",
                   trigger: "blur"
               }]
        },


        /**用户信用*/
        {
        label:"用户信用",
        prop:"userCredit",
        width:"150",
            addDisplay:false,
            editDisplay:false,
       fixed: false,
            hide:true,
            expand:true,
            rules: [{
                   required: true,
                   message: "用户信用",
                   trigger: "blur"
               }]
        },


        /**店铺*/
        {
        label:"店铺",
        prop:"storeId",
        width:"150",
            addDisplay:false,
            editDisplay:false,
         fixed: false,
            type:"select",
            props: {
                label: 'storeName',
                value: 'id'
            },
            dicMethod:'get',
            dicUrl:"/shop/storeApply/allList",
            rules: [{
                   required: true,
                   message: "店铺",
                   trigger: "blur"
               }]
        },
        /**QQ开放平台ID*/
        {
        label:"QQ开放平台ID",
        prop:"qqOpenid",
        width:"150",
            addDisplay:false,
            editDisplay:false,
            hide:true,
            expand:true,
       fixed: false,
            rules: [{

                   required: true,
                   message: "QQ开放平台ID",
                   trigger: "blur"
               }]
        },
        /**微信的开放平台ID*/
        {
        label:"微信的开放平台ID",
        prop:"wxOpenid",
        width:"150",
            addDisplay:false,
            editDisplay:false,
            hide:true,
            expand:true,
       fixed: false,
            rules: [{
                   required: true,
                   message: "微信的开放平台ID",
                   trigger: "blur"
               }]
        },
        // /**真实姓名*/
        // {
        //     label:"真实姓名",
        //     prop:"trueName",
        //     width:"150",
        //     fixed:false,
        //     hide:true,
        //     expand:true,
        //     addDisplay:false,
        //     editDisplay:false,
        // },
        // /**身份证号*/
        // {
        //     label:"身份证号",
        //     prop:"idNumber",
        //     width:"150",
        //     fixed:false,
        //     hide:true,
        //     expand:true,
        //     addDisplay:false,
        //     editDisplay:false,
        // },
        /**头像*/
        {
            label:"头像",
            prop:"photoId",
            width:"150",
            type:"upload",
            listType:'picture-img',
            loadText: '头像上传中，请稍等',
            fixed: false,
            hide:true,
            propsHttp: {
                name: 'label',
                url: 'url'
            },

            props: {
                label: 'label',
                value: 'url'
            },
            rules: [{
                required: true,
                message: "头像",
                trigger: "blur"
            }],
            action: 'http://localhost:3000/file/fileUplod?projectName=Tracer&modelName=UserHead',

        },

    ]

};

